package client.gui;



import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


import messages.MessageLogEveryoneOut;



import sharedspace.*;

/**
 * This class is a panel for Admin of the system to clear users that closed the program with sign-out. 
 * @author Amir S.
 * @author Jacob C.
 * @author Maya G.
 * @author Michael V.
 *
 */
public class GUI_Admin extends GUI_AbstractMainMenu {


    private User user = null;
	private JButton back = null;
	private JLabel jLabel = null;	
	public JButton logEveryoneOut = null;
	public Client_GUI ms=null;

	/**
	 * This is the default constructor
	 * @param MS
	 */
	public GUI_Admin(Client_GUI MS) {
		super(MainMenuType.ADMIN,MS);
		this.ms = MS;
		initiateAdmin();
		greetMsg.setText("Welcome "+MS.lg.getCurrentUsername()+"!");
		mainMenu.setText("Administrator");
	}

	/**
	 * This method initializes the Login screen
	 */
	private void initiateAdmin() {
			
		jLabel = new JLabel();
		jLabel.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 50));
		jLabel.setBounds(new Rectangle(384, 29, 212, 57));
		jLabel.setForeground(Color.BLUE);
		jLabel.setText("Admin");
		this.setSize(1000, 800);	
		this.setLayout(null);
		this.add(jLabel, null);
		this.background.add(getLogEveryoneOut());
	}
	
	public JButton getLogEveryoneOut() {
		if (logEveryoneOut == null) {
			logEveryoneOut = new JButton();
			logEveryoneOut.setText("Reset Login Status");
			logEveryoneOut.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 20));
			logEveryoneOut.setBounds(new Rectangle(43, 200, 246, 34));
			logEveryoneOut.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				
				MessageLogEveryoneOut msgLogEveryoneOut=new MessageLogEveryoneOut();
					try {
						ms.client.sendToServer(msgLogEveryoneOut);
					} catch (IOException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}			
					JOptionPane.showMessageDialog(null,ms.client.GetMessage().toString());
			}
		});
	}
	return logEveryoneOut;
}

}  
